1. Technical Field
This invention generally relates to object oriented programming and more specifically relates to an apparatus and method for accessing object oriented objects in an object oriented system.
2. Background Art
Since the dawn of the computer age, computer systems have evolved into extremely sophisticated devices, and computer systems may be found in many different settings. Computer systems typically include a combination of hardware, such as semiconductors and circuit boards, and software, also known as computer programs. As advances in semiconductor processing and computer architecture push the performance of the computer hardware higher, more sophisticated computer software has evolved to take advantage of the higher performance of the hardware, resulting in computer systems today that are much more powerful than just a few years ago.
Computer systems typically include operating system software that controls the basic function of the computer, and one or more software application programs that run under the control of the operating system to perform desired tasks. For example, a typical IBM Personal Computer may run the OS/2 operating system, and under the control of the OS/2 operating system, a user may execute an application program, such as a word processor. As the capabilities of computer systems have increased, the application software programs designed for high performance computer systems have become extremely powerful. Additionally, software development costs have continued to rise because more powerful and complex programs take more time, and hence more money, to produce.
One way in which the performance of application software programs has been improved while the associated development costs have been reduced is by using object oriented programming concepts. The goal of using object oriented programming is to create small, reusable sections of program code known as xe2x80x9cobjectsxe2x80x9d that can be quickly and easily combined and re-used to create new programs. This is similar to the idea of using the same set of building blocks again and again to create many different structures. The modular and re-usable aspects of objects will typically speed development of new programs, thereby reducing the costs associated with the development cycle. In addition, by creating and re-using a comprehensive set of well-tested objects, a more stable, uniform, and consistent approach to developing new computer programs can be achieved.
Modern object oriented programming languages have features that improve the convenience of programming in those languages. For example, the Java programming language developed by Sun Microsystems defines a xe2x80x9csmart referencexe2x80x9d for an object, which is a reference to the object that contains intelligence regarding when and how the object is referenced by other objects and when and how the object is created and deleted. In the C++ programming language, these types of smart references are referred to as xe2x80x9csmart pointersxe2x80x9d. For the discussion herein, the term xe2x80x9csmart pointerxe2x80x9d is used to refer to active pointers and references to objects. A reference is xe2x80x9cactivexe2x80x9d if it is used to directly access an object. A reference is xe2x80x9cpassivexe2x80x9d if it is not used to directly access an object, but if it can determine whether the object should be accessed.
Smart pointers are especially useful for heap-based objects, referred to herein as xe2x80x9cmanaged objectsxe2x80x9d. These managed objects typically contain a reference count to keep track of all references to the object. As long as the reference count is non-zero, the object is still being referenced. When the reference count goes to zero, the managed object may be deleted. The smart pointers increment the reference count of a managed object when each smart pointer is created, and the reference count is decremented after deleting a smart pointer to the object. Thus, if a smart pointer holds an active reference to a managed object, the managed object will not be deleted. Once all active references are deleted, the reference count goes to zero, and the managed object can then be deleted.
While reference counting is powerful, it suffers from some problems. For example, reference counting cannot detect circular references. A circular reference is when two or more objects refer to one another, preventing the reference count of any of the objects from going to zero. This situation results in maintaining objects in memory that could and should be deleted. In addition, there is no mechanism for granting exclusive access to a managed object. Without a mechanism for solving the problems of known smart pointers and reference counting, the computer industry will continue to suffer from object oriented computer systems that have the undesirable features discussed above.
A smart passive reference to an object oriented object provides control over creation and deletion of the object it references. A reference count is incremented when an active reference to an object is created, and is decremented when an active reference to the object is deleted. The smart passive reference allows suspending the activity of a thread until no threads have active references to the object. In addition, the smart passive reference can be used to invalidate the smart passive references in other threads, thereby allowing a thread to obtain exclusive access to an object. The smart passive reference also provides an interface to cause the managed object to be deleted when the reference count goes to zero.
The foregoing and other features and advantages of the invention will be apparent from the following more particular description of preferred embodiments of the invention, as illustrated in the accompanying drawings.